package com.jt.controller;

import com.jt.pojo.Item;
import com.jt.pojo.ItemCatParam;
import com.jt.service.ItemCatParamService;
import com.jt.service.ItemCatService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/itemCatParam")
public class ItemCatParamController {

    @Autowired
    private ItemCatParamService itemCatParamService;

    @GetMapping("/findItemCatParamListByType")
    public SysResult findItemCatParamListByType(ItemCatParam itemCatParam){

        return SysResult.success(itemCatParamService.findItemCatParamListByType(itemCatParam));
    }

    /**
     *
     * @param itemCatParam
     * @return SysResult
     */
    @PostMapping("/addItemCatParam")
    public SysResult addItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.addItemCatParam(itemCatParam);
        return SysResult.success();
    }

    /**
     * 实现商品分类的更新
     *  URL:/itemCatParam/updateItemCatParam
     * @param itemCatParam
     * @return SysResult
     */
    @PutMapping("/updateItemCatParam")
    public SysResult updateItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.updateItemCatParam(itemCatParam);
        return SysResult.success();
    }

    @DeleteMapping("/deleteItemCatParamById")
    public SysResult deleteItemCatParamById(@PathVariable Integer id){
        itemCatParamService.deleteItemCatParamById(id);
        return SysResult.success();
    }

}
